<html>
<head>
<title>tooLAME Psychoacoustic Models</title>
<style>	
<!-- BODY { BACKGROUND: #FFFFFF; COLOR: #000000; FONT-SIZE: 10pt; FONT-FAMILY: verdana, sans-serif }
	A { COLOR: #111177;  TEXT-DECORATION: none }
       TD { font-size: medium; font-weight:normal }
--!>
</STYLE>
</head>
<body>
<table border = 0 width="75%" align="center"><tr><td>
<h1>Psychoacoustic Models in tooLAME</h1>
<h3> Introduction </h3>
In MPEG audio encoding, a psychoacoustic model (PAM) is used to determine which are the sonically important parts of the waveform that is being encoded.  The PAM looks for loud sounds which may mask soft sounds, noise which may affect the level of sounds nearby, sounds which are too soft for us to hear and should be ignored and so on.  The information from the PAM is used to determine which parts of the spectrum should get more bits and thus be encoded at greater quality - and which parts are inaudible/unimportant and should thus get fewer bits.<p>
In MPEG Audio LayerII encoding, 1152 sound samples are read in - this constitutes a <i>frame</i>. For each frame the PAM outputs just <b>32</b> values (The values are the Signal to Masking Ratio [SMR] in that subband). This is important! There are only 32 values to determine how to alloctate bits for 1152 samples - this is a pretty coarse technique.<p>
The different PAMs listed below use different techniques to decide on these 32 values. Some models are better than others - meaning that the 32 values chosen are pretty good at spreading the bits where they should go.  Even with a really bad PAM (e.g. Model -1) you can still get satisfactory results a lot of the time. <P>
All of these models have strengths and weaknesses.  The model <i>you</i> end up using will be the one that produces the best sound for your ears, for your audio.  <p>

<h3> Psychoacoustic Model -1 </h3>
This PAM doesn't actually look at the samples being encoded to decide upon the output values.  There is simply a set of 32 default values which are used, regardless of input.<p>
<b>Pros</b>: Faaaast. Low complexity.<br>
<b>Cons</b>: Absolutely no attempt to consider any of the masking effects that would help the audio sound better<br>

<h3> Psychoacoustic Model 0 </h3>
This PAM looks at the sizes of the <i>scalefactors</i> for the audio and combines it with the Absolute Threshold of Hearing (ATH) to make the 32 SMR values.<p>
<b>Pros</b>: Faaast. Low complexity. Sounds better than PAM-1<br>
<b>Cons</b>: This model has absolutely no mathematical basis and does not use any perceptual model of hearing.  It simply juggles some of the numbers of the input sound to determine the values.<br>

<h3> Psychoacoustic Model 1 and 2</h3>
These PAMs are from the ISO standard. Just because they are the standard, doesn't mean that they are any good. Look at <a href="http://lame.sourceforge.net">LAME</a> which basically threw out the MP3 standard psycho models and made their own (GPSYCHO).<p>
<b>Pros</b>: A reference for future PAMs<br>
<b>Cons</b>: Terrible ISO code, buggy tables, poor documentation.<br>

<h3> Psychoacoustic Model 3</h3>
A re-implementation of psychoacoustic model 1.  ISO11172 was used as the guide for re-writing this PAM from the ground up.<p>
<b>Pros</b>: No more obscure tables of values from the ISO code. Hopefully a good base to work upon for tweaking PAMs<br>
<b>Cons</b>: At the moment, doesn't really sound any better than PAM1<br>

<h3>Psychoacoustic Model 4</h3>
A cleaned up version of PAM2.<p>
<b>Pros</b>: Faster than PAM2. No more obscure tables of values from the ISO standard. Hopefully a good base to work from for improving the PAMs<br>
<b>Cons</b>: Still has the same "warbling"/"Davros" problems as PAM2.<br>

<h3> Future psychoacoustic models </h3>
There's a heap that could be done. Unfortunately, I've got a set of tin ears, crappy speakers and a noisy computer room.  If you've got the capability to do proper PAM testing then please feel free to do so. Otherwise, I'll just keep plodding along with new ideas as they arise, such as:
<UL>
<LI> Temporal masking (there's no pre-echo or anything in tooLAME)
<LI> Left Right Masking
<LI> A PAM that's fully tuneable from the command line?
<LI> Graphical output of SMR values etc. Would allow better debugging of PAMs
<LI> Re-sampling routines
<LI> Low/High pass filtering
</UL>

</tr></td>
</body>
</html>
